
package br.com.aeternu.controleatendimento.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public final class DateUtil
{

   private DateUtil()
   {
   }

   public static boolean isUtil(Calendar calendar)
   {
      int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);

      if (dayOfWeek != Calendar.SATURDAY && dayOfWeek != Calendar.SUNDAY)
         return true;

      return false;
   }

   public static boolean isUtil(Date date)
   {
      Calendar calendar = Calendar.getInstance();
      calendar.setTime(date);

      return isUtil(calendar);
   }

   public static boolean isUtil(String date)
   {
      DateFormat df = new SimpleDateFormat();
      try
      {
         return isUtil(df.parse(date));
      }
      catch (ParseException e)
      {
      }

      return false;
   }

   public static String getDiaSemana(Date data)
   {
      Calendar cal = Calendar.getInstance();
      cal.setTime(data);

      switch (cal.get(Calendar.DAY_OF_WEEK))
      {
         case Calendar.SUNDAY:
            return "Domingo";
         case Calendar.MONDAY:
            return "Segunda-Feira";
         case Calendar.TUESDAY:
            return "Terça-Feira";
         case Calendar.WEDNESDAY:
            return "Quarta-Feira";
         case Calendar.THURSDAY:
            return "Quinta-Feira";
         case Calendar.FRIDAY:
            return "Sexta-Feira";
         case Calendar.SATURDAY:
            return "Sábado";
         default:
            return "N/A";
      }
   }
}
